import request from '../utils/request';

// 回款管理相关API
export const paymentApi = {
  // 根据项目ID查询回款列表
  getPaymentsByProjectId: (projectId) => {
    return request.get(`/api/payment/project/${projectId}`);
  },

  // 根据回款状态查询回款列表
  getPaymentsByPaymentStatus: (paymentStatus) => {
    return request.get(`/api/payment/status/${paymentStatus}`);
  },

  // 根据ID查询回款记录详情
  getPaymentById: (id) => {
    return request.get(`/api/payment/${id}`);
  },

  // 创建回款记录
  createPayment: (data) => {
    return request.post('/api/payment', data);
  },

  // 更新回款记录
  updatePayment: (id, data) => {
    return request.put(`/api/payment/${id}`, data);
  },

  // 更新回款状态
  updatePaymentStatus: (id, paymentStatus) => {
    return request.put(`/api/payment/${id}/status`, null, {
      params: { paymentStatus }
    });
  },

  // 计算项目总回款金额
  calculateTotalPayment: (projectId) => {
    return request.get(`/api/payment/project/${projectId}/total-amount`);
  },

  // 计算项目剩余待回款金额
  calculateRemainingAmount: (projectId) => {
    return request.get(`/api/payment/project/${projectId}/remaining-amount`);
  },

  // 批量创建回款记录
  batchCreatePayments: (data) => {
    return request.post('/api/payment/batch', data);
  },

  // 删除回款记录
  deletePayment: (id) => {
    return request.delete(`/api/payment/${id}`);
  }
};

